﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using YiSha.Util;
using YiSha.Util.Model;
using YiSha.Entity;
using YiSha.Model;
using YiSha.Admin.Web.Controllers;
using YiSha.Entity.YiDongYuan;
using YiSha.Business.YiDongYuan;
using YiSha.Model.Param.YiDongYuan;

namespace YiSha.Admin.Web.Areas.YiDongYuan.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-06-16 13:13
    /// 描 述：文件管理控制器类
    /// </summary>
    [Area("YiDongYuan")]
    public class BaseFileController : BaseController
    {
        private BaseFileBLL baseFileBLL = new BaseFileBLL();

        #region 视图功能

        [AuthorizeFilter("yidongyuan:basefile:view")]
        public ActionResult BaseFileIndex()
        {
            return View();
        }

        public ActionResult BaseFileForm()
        {
            return View();
        }

        public ActionResult ShowImg(long id)
        {
            ViewBag.ImgId = id;
            return View();
        }

        #endregion 视图功能

        #region 获取数据

        [HttpGet]
        [AuthorizeFilter("yidongyuan:basefile:search")]
        public async Task<ActionResult> GetListJson(BaseFileListParam param)
        {
            TData<List<BaseFileEntity>> obj = await baseFileBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("yidongyuan:basefile:search")]
        public async Task<ActionResult> GetPageListJson(BaseFileListParam param, Pagination pagination)
        {
            TData<List<BaseFileEntity>> obj = await baseFileBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<ActionResult> GetFormJson(long id)
        {
            TData<BaseFileEntity> obj = await baseFileBLL.GetEntity(id);
            return Json(obj);
        }

        #endregion 获取数据

        #region 提交数据

        [HttpPost]
        [AuthorizeFilter("yidongyuan:basefile:add,yidongyuan:basefile:edit")]
        public async Task<ActionResult> SaveFormJson(BaseFileEntity entity)
        {
            TData<string> obj = await baseFileBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("yidongyuan:basefile:delete")]
        public async Task<ActionResult> DeleteFormJson(string ids)
        {
            TData obj = await baseFileBLL.DeleteForm(ids);
            return Json(obj);
        }

        #endregion 提交数据
    }
}
